/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package TestCase.InstanceOf;

import TestCase.InvokeInterface.*;
import classgenerator.logic.FieldType;
import classgenerator.logic.Oracle;
import classgenerator.logic.OracleImpl;
import deadCodeRmv.StartMeDCR;
import java.util.ArrayList;
import takatuka.classreader.dataObjs.ClassFile;
import takatuka.classreader.dataObjs.MethodInfo;
import takatuka.classreader.logic.constants.FieldTypes;
import takatuka.classreader.logic.constants.JavaInstructionsOpcodes;
import takatuka.classreader.logic.factory.FactoryFacade;
import takatuka.classreader.logic.factory.FactoryPlaceholder;

/**
 *
 * @author irfan
 */
public class ClassImpleInterface extends StartMeDCR{
    
     public static void main(String args[]) throws Exception {
        new ClassImpleInterface().start(args);
    }
    @Override
    public void execute(String args[]) throws Exception {
        Oracle oracle = new OracleImpl();
        FactoryFacade factoryFacade = FactoryPlaceholder.getInstanceOf().getFactory();
        ClassFile cFile = oracle.createEmptyClassFile("ClassImpleInterface", "ClassImpleInterface.java");
        
        MethodInfo constrMethodInfo = oracle.addDefaultConstructor(cFile);
        ArrayList<FieldType> parm = new ArrayList<FieldType>();
        parm.add(new FieldType(FieldTypes.VOID));
        
         int defaultConstrRefInfo = oracle.addMethodRefInCP(cFile, cFile.getThisClass().intValueSigned(),
                oracle.getUTF8FromCP(cFile, constrMethodInfo.getNameIndex().intValueSigned()),
                oracle.getUTF8FromCP(cFile, constrMethodInfo.getDescriptorIndex().intValueSigned()));
                

        MethodInfo myMethod = oracle.addFunction(cFile, "my", null, new FieldType(FieldTypes.VOID));
        oracle.print(cFile, myMethod, "irfan");
         oracle.addInstruction(cFile, myMethod,
                factoryFacade.createInstruction(JavaInstructionsOpcodes.RETURN, myMethod.getCodeAtt()));
         cFile.setInterfaceCount(factoryFacade.createUn(1).trim(2));
          int InterfaceInfoIndex = oracle.addClassInfoInCP(cFile, oracle.addUTF8InCP(cFile, "Interface"));
          cFile.addInterfacesInfos(factoryFacade.createUn(InterfaceInfoIndex).trim(2));
        

        /**
         * Do the dead code removal and frame size automatic calculation.
         */
        super.execute(args);
    }
    
}
